/**
 * @author ens12ilt - ens12ple
 */

package utils;

import java.util.ArrayList;

public final class ArrayUtils {

	/**
	 * 
	 * @param array array to add up.
	 * @return the computed sum.
	 */
	public static double sum(ArrayList<Double> array){
		double sum = 0;
		for(Double d : array){
			sum += d;
		}
		return sum;
	}
	
	/**
	 * 
	 * @param array array from which to compute the norm
	 * @return the computed norm
	 */
	public static double norm(ArrayList<Double> array){
		double norm2 = 0;
		for(Double d : array){
			norm2 += Math.pow(d, 2);
		}
		return Math.sqrt(norm2);
	}
}
